# linux ffmpeg 配置
set(FFMPEG_CONFIGURE
  --target-os=linux
  #--arch=${CMAKE_SYSTEM_PROCESSOR}
  #--cpu=${CMAKE_HOST_SYSTEM_PROCESSOR}
  #--cc=${CMAKE_C_COMPILER}
  #--cxx=${CMAKE_CXX_COMPILER}
CACHE STRING "ffmpeg configure" FORCE)
# --- 调试专用配置 ---
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    list(APPEND FFMPEG_CONFIGURE "--enable-debug=3") # 开启调试信息
    list(APPEND FFMPEG_CONFIGURE "--disable-optimizations") # 禁用优化
    list(APPEND FFMPEG_CONFIGURE "--disable-small") # 禁用小优化
    list(APPEND FFMPEG_CONFIGURE "--disable-stripping") # 禁用 stripping
    list(APPEND FFMPEG_CONFIGURE "--disable-asm") # 禁用汇编
    list(APPEND FFMPEG_CONFIGURE "--disable-inline-asm") # 禁用内联汇编
    list(APPEND FFMPEG_CONFIGURE "--disable-neon")          # 避免汇编
    # --- 许可 ---
    list(APPEND FFMPEG_CONFIGURE "--enable-gpl")
    list(APPEND FFMPEG_CONFIGURE "--enable-nonfree")
    list(APPEND FFMPEG_CONFIGURE "--enable-version3")
    if(CMAKE_POSITION_INDEPENDENT_CODE)
        list(APPEND FFMPEG_CONFIGURE "--extra-cflags=-g3")
        list(APPEND FFMPEG_CONFIGURE "--extra-cflags=-O0")
        list(APPEND FFMPEG_CONFIGURE "--extra-cflags=-fno-omit-frame-pointer")
        list(APPEND FFMPEG_CONFIGURE "--extra-cflags=-fPIC")
        list(APPEND FFMPEG_CONFIGURE "--extra-ldflags=-Wl,--gc-sections")
    endif()
endif()

# 配置 Release 发布版
if(CMAKE_BUILD_TYPE STREQUAL "Release")
# --- 性能优化 ---
    list(APPEND FFMPEG_CONFIGURE "--enable-gpl")
    list(APPEND FFMPEG_CONFIGURE "--enable-nonfree")
    list(APPEND FFMPEG_CONFIGURE "--enable-version3")
    list(APPEND FFMPEG_CONFIGURE "--enable-optimizations") # 启用优化
    list(APPEND FFMPEG_CONFIGURE "--enable-pthreads") # 启用线程
    list(APPEND FFMPEG_CONFIGURE "--enable-asm") # 启用汇编
    list(APPEND FFMPEG_CONFIGURE "--enable-inline-asm") # 启用内联汇编
    list(APPEND FFMPEG_CONFIGURE "--enable-neon") # 启用 NEON
    list(APPEND FFMPEG_CONFIGURE "--enable-hardcoded-tables") # 启用硬编码表
    list(APPEND FFMPEG_CONFIGURE "--enable-small") # 启用小优化
    if(CMAKE_POSITION_INDEPENDENT_CODE)
        list(APPEND FFMPEG_CONFIGURE "--optflags=-O2")
        list(APPEND FFMPEG_CONFIGURE "--optflags=-fno-math-errno")
        list(APPEND FFMPEG_CONFIGURE "--optflags=-fno-signed-zeros")
        list(APPEND FFMPEG_CONFIGURE "--optflags=-fno-trapping-math")
        list(APPEND FFMPEG_CONFIGURE "--extra-cflags=-fPIC")
        list(APPEND FFMPEG_CONFIGURE "--extra-cflags=-fdata-sections")
        list(APPEND FFMPEG_CONFIGURE "--extra-cflags=-ffunction-sections")
        list(APPEND FFMPEG_CONFIGURE "--extra-ldflags=-s")
        list(APPEND FFMPEG_CONFIGURE "--extra-ldflags=-Wl,--gc-sections") # 额外的链接标志
    endif()
endif()








